package com.cskaoyan.controller;

import com.cskaoyan.bean.Issue;
import com.cskaoyan.bean.SearchHistory;
import com.cskaoyan.service.IssueService;
import com.cskaoyan.vo.BaseRespVo;
import com.cskaoyan.vo.IssueVo;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.sun.xml.internal.bind.v2.TODO;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @description:
 * @author: libugu@cskaoyan.com
 * @date 2021/4/9 - 12:20
 */
@RestController
public class IssueController {


    @Autowired
    IssueService issueService;

    @RequestMapping("admin/issue/list")
    public BaseRespVo list(Integer page, Integer limit, String sort, String order, String question){

        IssueVo issueVo = issueService.query(page,limit,sort,order,question);
        return BaseRespVo.ok(issueVo);
    }


    // 待完善
    @RequestMapping("admin/issue/create")
    public BaseRespVo create(@RequestBody Issue issue){

        Issue solve = issueService.solve(issue);

        return BaseRespVo.ok(issue);
    }

    @RequestMapping("admin/issue/delete")
    public BaseRespVo delete(@RequestBody Issue issue){

        issueService.delete(issue);
        return BaseRespVo.ok();
    }

    @RequestMapping("admin/issue/update")
    public BaseRespVo update(@RequestBody Issue issue){

       Issue issue1 = issueService.update(issue);

       return BaseRespVo.ok(issue1);
    }

}
